package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class PWDemo {
    public static void main(String[] args) throws IOException {
        //最常用写入字符串方式：
        PrintWriter pw = new PrintWriter("pw.txt");
        //PrintWrite底层套用了BufferWrite缓冲字符输出流、OutputStreamWrite转换字节输出流、FileOutputStream低级流
        pw.println("和我在成都的街头走一走");
        pw.println("啦啦啦啦啦啦啦啦啦啦啦");
        System.out.println("写出完毕！");
        pw.close();


        FileOutputStream fos = new FileOutputStream("pw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        bw.write("和我在成都的街头走一走");
        bw.write("啦啦啦啦啦啦啦啦啦啦啦");
        System.out.println("写出完毕！");
        bw.close();

    }
}
